package vn.gq.tym.utils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.StreamCorruptedException;

public class IOMaster {
	
	public IOMaster() {
	}
	
	public static Object readObject(String path) throws StreamCorruptedException, IOException, ClassNotFoundException {
		Object obj = null;
		FileInputStream fis = new FileInputStream(path);
		ObjectInputStream ois = new ObjectInputStream(fis);
		obj = ois.readObject();
		fis.close();
		return obj;
	}
	
	public static void writeObject(String path, Object obj) throws IOException {
		FileOutputStream fos = new FileOutputStream(path);
		ObjectOutputStream oos = new ObjectOutputStream(fos);
		oos.reset();
		oos.writeObject(obj);
		oos.flush();
		oos.close();
	}
}
